package com.object3D
{
	import away3d.containers.ObjectContainer3D;
	import away3d.entities.Mesh;
	
	import com.utils.PowerLoader;
	import com.utils.ZipResolve;
	import com.vo.MeshVo;
	import com.vo.PartVo;

	public class NewBaseWheel
	{
		private var meshVo:MeshVo;
		protected var wheel3D:ObjectContainer3D;//3D视图容器
		protected var wheel:Mesh;
		
		public function show(parent:ObjectContainer3D,
							 x:Number = 0,y:Number = 0,z:Number = 0,isLeft:Boolean = false,
							 meshVo:MeshVo = null):void{
			this.meshVo = meshVo;
			initFace();
			parent.addChild(wheel3D);
			wheel3D.x = x;// / parent.scaleX;
			wheel3D.y = y;// / parent.scaleY;
			wheel3D.z = z;// / parent.scaleZ;
			if(isLeft)wheel3D.rotationY = 180;
		}
		
		private function initFace():void
		{
			if(wheel3D == null){
				wheel3D = new ObjectContainer3D();
				init();
			}
		}
		
		private function init():void
		{
			loadModel();
		}
		
		private function loadModel():void
		{
			if(meshVo != null)PowerLoader.loadByte(meshVo.meshPath,loadZip,meshVo.meshPath);
		}
		
		protected function loadZip(zipByteArray:Object,path:String):void
		{
			ZipResolve.loadByteArray(zipByteArray,loadMesh,path);
		}
		
		protected function loadMesh(mesh:Mesh, name:Object=null):void
		{
			wheel = mesh.clone() as Mesh;
			wheel.scale(200);
			wheel3D.addChild(wheel);
		}
		/**
		 * 替换轮毂素材
		 * @param pvo
		 */		
		public function replaceWheel(pvo:PartVo):void{
//			PowerLoader.loadFile(pvo.meshPath,loadMesh,'wheel');
		}
		
	}
}